package com.geekstudy.week3.http;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class HttpOKProvider implements HttpInterface{


    @Override
    public String get(String url) {
        String responseText = null;
        System.out.println("HttpOKProvider url:" + url);
        try {
            OkHttpClient okHttpClient = new OkHttpClient();
            Request request = new Request.Builder().url(url).build();
            Response response = okHttpClient.newCall(request).execute();
            responseText = response.body().string();
        } catch(Exception e) {
            System.out.println("HttpOKProvice url:" + url + " exception:" + e.getMessage());
            e.printStackTrace();
        }
        return responseText;
    }
}
